﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Documents;

namespace RaSuperGrid.SuperGrid.Adorners
{
    public class DataGridTextAdornerColumn : DataGridTextColumn 
    { 
        public static readonly DependencyProperty AdornerTemplateProperty 
                                                    = DependencyProperty.Register(  "AdornerTemplate", ///< Name   
                                                                                    typeof(DataTemplate), ///< Type
                                                                                    typeof(DataGridTextAdornerColumn), ///< Owner
                                                                                    new FrameworkPropertyMetadata(null)); ///< Metadata
        
        public DataTemplate AdornerTemplate 
        { 
            get { return (DataTemplate)GetValue(AdornerTemplateProperty); } 
            set { SetValue(AdornerTemplateProperty, value); } 
        } 
        
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem) 
        { 
            var layer = AdornerLayer.GetAdornerLayer(cell); 
            layer.Add(new TemplateAdorner(cell, dataItem, AdornerTemplate)); 
            return base.GenerateElement(cell, dataItem); 
        } 
    }
}
